package com.jtx.miaoah2.Cache;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author 季台星
 * @Date 2023 07 27 14 28
 */
@Component
public class HotKeyLocalCache {
    @Autowired
    private HotCache hotCache;

    /**
     * 本地缓存对象
     */
    public Cache<Long, String> localCache = CacheBuilder.newBuilder()
            .maximumSize(500)
            .expireAfterAccess(60, TimeUnit.SECONDS)
            .build();

    /**
     * 返回本地缓存，如果不存在则为空
     * @param key
     * @return
     */
    public String getGoodsInfoByLocalCache(Long key){
        return localCache.getIfPresent(key);
    }



}
